package basicJava.enumType.enumType2;


/**
 * Switch
 * @author Administrator
 * 在JDK1.6 之前，Switch只能接受int ，char，enum类型的参数
 * 使用enum，可以让我们的代码的可读性更强 
 */

enum Signal {
	GREEN,YELLOW,RED
}
public class TrafficLight {
	private Signal signal;
	public TrafficLight(Signal signal){
		this.signal = signal;
	}
	
	public void change(){
		switch (signal) {
		case GREEN:
			signal = Signal.YELLOW;
			break;
		case YELLOW:
			signal = Signal.RED;
			break;
		case RED:
			signal = Signal.GREEN;
			break;
		default:
			break;
		}
	}
	
	public static void main(String[] args){
		Signal signal = Signal.RED;
		TrafficLight trafficLight = new TrafficLight(signal);
		trafficLight.change();
		System.out.println(trafficLight.signal);
	}
}
